package cn.foreknow.mapping;

import java.util.HashMap;
import java.util.Map;

/**
 * 工厂类
 */
public class MappingFactory {
    private static MappingFactory mappingFactory = null;
    private static Map<String,EntityMapping> maps = new HashMap<>();
    public static final String FOOD_MAPPING = "foodmapping";

    /**
     * 单例
     */
    public static MappingFactory getInstance() {
        //如果为空，将xxxMapping对象保存到Map集合中
        if (mappingFactory == null){
            mappingFactory = new MappingFactory();
            mappingFactory.maps.put(FOOD_MAPPING,new FoodMapping());
        }
        return mappingFactory;
    }
    //从Map集合中获取元素的方法
    public EntityMapping getMap(String key){
        return maps.get(key);
    }
}
